<template>
  <link rel="stylesheet" href="//at.alicdn.com/t/c/font_4682916_9ezkkv7usl.css">
    <div class="box">
      <span>忘记密码</span>
      <div class="content1">
        <div class="phone">
            <el-select v-model="value" clearable placeholder="+86" style="width: 80px;margin-right: 30px;" >
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>

            <el-input v-model="phoneNumber"  placeholder="手机号" style="width: 290px;margin: 10px 0;"  clearable />
        </div>
        
        <el-input v-model="code"  placeholder="输入验证码" style="width: 400px;margin: 10px 0;"  clearable >
          <template #append>
          <div class="iconfont icon-yanzheng"></div>  
                发送验证码
            </template>
        </el-input>

        <el-input v-model="password"  placeholder="输入密码"  style="width: 400px;margin: 10px 0;" show-password clearable />

        <el-button v-for="button in buttons" :key="button.text" :type="button.type" link>
        {{ button.text }}
        </el-button>
        
      </div>
      <div class="footer">
        <el-button @click="certain" class="button" type="primary" style="width: 200px;">确定</el-button>
      </div>
    </div>
  </template>
  
  <script setup>
  import { ref } from 'vue'
  import { useRouter } from "vue-router";
  const router = useRouter();
  const todos=ref([])
  const phoneNumber = ref('')
  const code = ref('')
  const password = ref('')
  
  const buttons = [
    { type: 'info', text: '密码要求6-16位，至少包含数字、字母、符号两种元素' },
  ]
  const value = ref('')
  const options = [
  {value: '中国',label: '+86',},
  {value: '中国香港',label: '+852',},
  {value: '中国台湾',label: '+886',},
  {value: '中国澳门',label: '+531',},
  {value: '美国',label: '+1',},
  {value: '加拿大',label: '+1',},
]

  const certain=()=>{
    // 重定义值
    let phoneNumbers=phoneNumber.value
    let codes=code.value
    let passwords=password.value
    // 赋值给数组
    let todo = { id: Date.now(), phoneNumbers, codes, passwords};
    todos.value = todo;

    const msg =  phoneNumbers !==''&&codes!==''&&passwords!==''
    if(msg){
      alert('密码设置成功')
      router.push({ path: "/login" });
    }else{
      alert('请完善信息')
    }
  }
  </script>
  
  <style lang="scss" scoped>
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  .box {
    width: 500px;
    height: 300px;
    border: 2px solid skyblue;
    margin: 50px auto;
    border-radius: 10px;
    span{
      display: block;
      font-size: 30px;
      text-align: center;
      color: skyblue;
    }
    .content1{
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: center;
      margin: 5px 0;
      .phone{
        display: flex;
        justify-content: space-around;
        align-items: center;
      }
    }
    
    .content2{
      display: flex;
      justify-content: end;
      margin-right: 95px;
      margin-top: 10px;
    }
    .footer{
      display: flex;
      justify-content: space-around;
      align-items: center;
      .button{
        width: 100px;
        margin-top: 10px;
      }
    }
  }
  </style>